package hyg.q2;

import java.util.ArrayList;
import java.util.Arrays;

public class Solution {
    public String myResult(int[] a, int[] b) {
        int bmin;
        int[] aClone = a.clone();
        Arrays.sort(aClone);
        int amin = aClone[0];
        ArrayList<Integer> indexs = new ArrayList();
        for (int i = 0 ; i < a.length ; i++) {
            if (a[i] == amin)
                indexs.add(i);
        }
        int[] arrB = new int[indexs.size()];
        if (indexs.size() > 1) {
            for (int i = 0 ; i < indexs.size() ; i++) {
                arrB[i] = b[indexs.get(i)];
            }
            Arrays.sort(arrB);
            bmin = arrB[0];
        }else
            bmin = b[indexs.get(0)];
        return amin + "," + bmin;
    }


    public static void main(String[] args) {
        int[] a = {1, 2, 1, 4, 5, 1, 2, 3, 4, 5};
        int[] b = {4, 3, 2, 5, 6, 3, 4, 5, 6, 7};
        System.out.println((new Solution()).myResult(a,b));

    }
}
